package com.yuwei.device.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.yuwei.base.BaseViewModel
import com.yuwei.http.ApiService
import com.yuwei.http.entity.DeviceEntity
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class DeviceViewModel @Inject constructor(
    val apiService: ApiService
): BaseViewModel() {
    val getDeviceSuccess by lazy {
        MutableLiveData<DeviceEntity>()
    }
    fun getDevice(){
        viewModelScope.launch {
            executeNetwork({
                apiService.getDevices()
            },getDeviceSuccess::postValue)
        }
    }
}